<?php
abstract class htmllist extends htmlwidget {
	public $items = array();

	public function __toString(){

		//opening tag
		$this->html = '<' . $this->tag;

		foreach ( $this->attributes as $key => $value){
			if ( ! empty($value) || strlen($value)){
				$this->html .= ' ' . $key . '="' . $value . '"';
			}
		}
		$this->html .= '>' . "\n";

		//list items
		foreach ( $this->items as $item){
			if ( $item instanceof htmlwidget ){
				$this->html .= "\n\t" . '<li>' . "\n\t\t"  . $item->getHtml() . "\n\t\n" . '</li>' . "\n";
			} else {
				$this->html .= "\t" . '<li>' . $item . '</li>' . "\n";
			}
		}

		//closing tag
		$this->html .= "\n</" . $this->tag . ">\n";
		return $this->html;
	}


	public function setItems($items){
		if ( is_array($items)){
			$this->items = $items;
		}
	}

	public function addItem($item){
		$this->items[] = $item;
	}

}
?>